<template>
  <el-dialog title="风险前筛" :visible.sync="dialogVisible" width="900px">
    <h2>{{ cert_name }}风险前筛详情</h2>
    <br>
    <el-row>
      <el-col :span="8">报告生成时间：{{start_at }}</el-col>
      <el-col :span="8">订单ID：{{editItem.id || editItem.order_id }}</el-col>
    </el-row>
    <br>
    <el-row>
      <el-col>
        <div style="margin-bottom:10px;text-align:center">{{strategy_details?.name||''}}</div>
        <div style="text-align:center">
          <el-progress type="circle" :percentage="allData.score" :format="format"></el-progress>
        </div>
        <div style="padding:10px 0px;text-align:center">注:该风险场景的风险分值/营销场景为营销价值分，正常为0-100。<br/>特殊情况：-1 表示未查得，-99 表示查询异常。</div>
      </el-col>
    </el-row>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getAntRiskData } from '@/api/order'
export default {
  props: {
    editItem: {
      type: Object,
      default: () => ({})
    },
  },
  data() {
    return {
      dialogVisible: false,
      cert_name: '',
      start_at: '',
      level: '',
      allData: [],
      strategy_details:[]
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getList()
        })
      }
    }
  },
  methods: {
    format(percentage){
      return percentage==percentage?percentage.toFixed(2):'0'
    },
    getList() {
      // 1 额度评级分V2
      // 2 反欺诈价值分V4
      // 3 风险前筛V1
      // 4 经济能力评级分
      // 5 信贷洞察分V3
      let params={
        num:'3',
        orderId:this.editItem?.id || this.editItem?.order_id,
        cert_name:this.editItem?.authentic?.cert_name || this?.editItem?.cert_name,
        cert_no:this.editItem?.authentic?.cert_no|| this.editItem?.cert_no,
        mobile:this.editItem.mobile
      }
      getAntRiskData(params).then(res => {
        this.allData=res.model_details[0]
        this.start_at=res.start_at
        this.cert_name=res.cert_name
        this.strategy_details=res.strategy_details[0]||[]
        if(this.allData.score==-1){
          
          this.$message({
            message: '用户未查得',
            type: 'error'
          })
        }else if(this.allData.score==-99){
          this.$message({
            message: '查询异常',
            type: 'error'
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
